ABC009 C - 辞書式順序ふたたび
提出
WA
code: python
n, k = map(int, input().split())
s = input()
s_r = sorted(s)
for i in range(len(s)):
s_r.pop(0)
else:
if (k < 2):
continue
else:
k -= 2
s_r.pop(0)
print(s)
解答
code: python
import copy
n, k = map(int, input().split())
s = input()
ss = sorted(s)
# print(s)
# print(ss)
t = ''
# ここまでの不一致文字数
count = 0
for i in range(n):
for v in ss:
t += v
ss.remove(v)
break
else:
# tmp := 仮の不一致文字数
tmp = 1
ssc = copy.copy(ss)
ssc.remove(v)
for j in range(i+1, n):
else:
tmp += 1
if count + tmp <= k:
t += v
ss.remove(v)
count += 1
break
print(t)
テーマ
メモ
提出
code: python
from collections import Counter
n, k = map(int, input().split())
s = list(input())
ss = sorted(s)
# print(s)
# print(ss)
t = []
idx = 0
while k > -1:
nexts = ss.pop(0)
t.append(s.pop(0))
idx += 1
else:
i = s.index(nexts)
cs = Counter("".join(s)idx+1:) css = Counter("".join(ss)idx+1:) print(cs)
print(css)